package com.haoshuang.zhouzhoubang.ui.page.order.scan

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.haoshuang.zhouzhoubang.model.bean.HexiaoOrderBean
import com.haoshuang.zhouzhoubang.model.bean.HexiaoOrderInfoBean
import com.haoshuang.zhouzhoubang.model.bean.OrderDetailBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.ResponseBean
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class ScanViewModel : BaseViewModel() {

    /**
     * 获取订单详情
     */
    val getHexiaoOrderInfoData = StatefulMutableLiveData<ResponseBean<HexiaoOrderInfoBean>>()
    fun getHexiaoOrderInfo(hexiao_code: String?) = netRequest {
        start { getHexiaoOrderInfoData.value = StateData.Loading }
        request { ApiRepo.getHexiaoOrderInfo(hexiao_code)  }
        success { getHexiaoOrderInfoData.value = StateData.Success(it) }
        error { code, msg ->
            getHexiaoOrderInfoData.value = StateData.Error(code, msg)
        }
    }

    val hexiaoOrderData = StatefulMutableLiveData<ResponseBean<Any>>()
    fun hexiaoOrder(hexiao_code: String?) = netRequest {
        start { hexiaoOrderData.value = StateData.Loading }
        request { ApiRepo.hexiaoOrder(hexiao_code)  }
        success { hexiaoOrderData.value = StateData.Success(it) }
        error { code, msg ->
            hexiaoOrderData.value = StateData.Error(code, msg)
        }
    }



}